﻿using System;
using System.Configuration;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SchEduApp
{

    public sealed class ObjectiveConfigurationSection : ConfigurationSection
    {
        public ObjectiveConfigurationSection()
        {
        }
        [ConfigurationProperty("objectiveItems", IsDefaultCollection = true)]
        public ObjectiveItemCollection ObjectiveItems
        {
            get
            {
                return (ObjectiveItemCollection)base["objectiveItems"];
            }
        }
    }
    public sealed class ObjectiveItemCollection : ConfigurationElementCollection
    {
        protected override ConfigurationElement CreateNewElement()
        {
            return new ObjectiveItem();
        }
        protected override object GetElementKey(ConfigurationElement element)
        {
            return ((ObjectiveItem)element).Name;
        }
        public override ConfigurationElementCollectionType CollectionType
        {
            get
            {
                return ConfigurationElementCollectionType.BasicMap;
            }
        }
        protected override string ElementName
        {
            get
            {
                return "objectiveItem";
            }
        }
        public ObjectiveItem this[int index]
        {
            get
            {
                return (ObjectiveItem)BaseGet(index);
            }
            set
            {
                if (BaseGet(index) != null)
                {
                    BaseRemoveAt(index);
                }
                BaseAdd(index, value);
            }
        }


    }
    public sealed class ObjectiveItem : ConfigurationElement
    {
        [ConfigurationProperty("name", IsKey = true, IsRequired = true)]
        public string Name
        {
            get
            {
                return (string)base["name"];
            }
            set
            {
                base["name"] = value;
            }
        }
        [ConfigurationProperty("class", IsRequired = false)]
        public string Class
        {
            get
            {
                return (string)base["class"];
            }
            set
            {
                base["class"] = value;
            }
        }
        [ConfigurationProperty("assembly", IsRequired = false)]
        public string Assembly
        {
            get
            {
                return (string)base["assembly"];
            }
            set
            {
                base["assembly"] = value;
            }
        }

    }

}

